このページはECMAScript® 2020 Language Specification13 ECMAScript Language: Statements and Declarations章をJavaScriptの学習目的で私的に日本語訳したものであり、直訳と意訳および推測が混在しています。そのため内容については正確ではない可能性があります。正確な情報を知りたい場合は、原文をご覧ください。また一部訳者によるコメントが含まれていることがあります。※このサイトの内容で損害や不利益を受けたとしても当方は一切の責任を負いません。

構文:

Statement[Yield, Await, Return] :
BlockStatement[?Yield, ?Await, ?Return]
VariableStatement[?Yield, ?Await]
EmptyStatement
ExpressionStatement[?Yield, ?Await]
IfStatement[?Yield, ?Await, ?Return]
BreakableStatement[?Yield, ?Await, ?Return]
ContinueStatement[?Yield, ?Await]
BreakStatement[?Yield, ?Await]
[+Return]ReturnStatement[?Yield, ?Await]
WithStatement[?Yield, ?Await, ?Return]
LabelledStatement[?Yield, ?Await, ?Return]
ThrowStatement[?Yield, ?Await]
TryStatement[?Yield, ?Await, ?Return]
DebuggerStatement
Declaration[Yield, Await] :
HoistableDeclaration[?Yield, ?Await, ~Default]
ClassDeclaration[?Yield, ?Await, ~Default]
LexicalDeclaration[+In, ?Yield, ?Await]
HoistableDeclaration[Yield, Await, Default] :
FunctionDeclaration[?Yield, ?Await, ?Default]
GeneratorDeclaration[?Yield, ?Await, ?Default]
AsyncFunctionDeclaration[?Yield, ?Await, ?Default]
AsyncGeneratorDeclaration[?Yield, ?Await, ?Default]
BreakableStatement[Yield, Await, Return] :
IterationStatement[?Yield, ?Await, ?Return]
SwitchStatement[?Yield, ?Await, ?Return]

13.1 ステートメントセマンティクス(Statement Semantics)

13.1.1 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. false を返す

13.1.2 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. false を返す

13.1.3 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. false を返す
  1. labelSet のすべての要素が追加された iterationSet のコピーを newIterationSet とする
  2. 引数 newIterationSet« » を使用して IterationStatementContainsUndefinedContinueTarget を返す

13.1.4 静的セマンティクス(Static Semantics): DeclarationPart

  1. ClassDeclaration を返す
  1. LexicalDeclaration を返す

13.1.5 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. 空の新規List を返す

13.1.6 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. 空の新規List を返す

13.1.7 ランタイムセマンティクス(Runtime Semantics): LabelledEvaluation

引数 labelSet を使用。

  1. 引数 labelSet を使用して IterationStatementLabelledEvaluationstmtResult とする
  2. stmtResult.[[Type]] が break なら、
    1. stmtResult.[[Target]] が empty なら、
      1. stmtResult.[[Value]] が empty なら、NormalCompletion(undefined) を stmtResult にセットする
      2. 異なるなら、NormalCompletion(stmtResult.[[Value]]) を stmtResult にセットする
  3. Completion(stmtResult) を返す
  1. SwitchStatement の評価結果を stmtResult とする
  2. stmtResult.[[Type]] が break なら、
    1. stmtResult.[[Target]] が empty なら、
      1. stmtResult.[[Value]] が empty なら、NormalCompletion(undefined) を stmtResult にセット
      2. 異なるなら、 NormalCompletion(stmtResult.[[Value]]) を stmtResult にセットする
  3. Completion(stmtResult) を返す
BreakableStatementは、ラベルのないBreakStatementを介して終了できます。

13.1.8 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. NormalCompletion(empty) を返す
  1. FunctionDeclaration の評価結果を返す
  1. 空の新規ListnewLabelSet とする
  2. 引数 newLabelSet を使用して BreakableStatementLabelledEvaluation の実行結果 を返す

13.2 ブロック(Block)

構文:

BlockStatement[Yield, Await, Return] :
Block[?Yield, ?Await, ?Return]
Block[Yield, Await, Return] :
{StatementList[?Yield, ?Await, ?Return]opt }
StatementList[Yield, Await, Return] :
StatementListItem[?Yield, ?Await, ?Return]
StatementList[?Yield, ?Await, ?Return] StatementListItem[?Yield, ?Await, ?Return]
StatementListItem[Yield, Await, Return] :
Statement[?Yield, ?Await, ?Return]
Declaration[?Yield, ?Await]

13.2.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

  • StatementListLexicallyDeclaredNames に重複するエントリが含まれている場合、構文エラーです。
  • StatementListLexicallyDeclaredNamesの要素がStatementListVarDeclaredNamesにもある場合は、構文エラーです。

13.2.2 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

Block : {}
  1. false を返す
  1. 引数 labelSet を使用して StatementListContainsDuplicateLabelshasDuplicates とする
  2. hasDuplicatestrue なら、 true を返す
  3. 引数 labelSet を使用して StatementListItemContainsDuplicateLabels の実行結果を返す
  1. false を返す

13.2.3 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

Block : {}
  1. false を返す
  1. 引数 labelSet を使用して StatementListContainsUndefinedBreakTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 labelSet を使用して StatementListItemContainsUndefinedBreakTarget の実行結果を返す
  1. false を返す

13.2.4 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

Block : {}
  1. false を返す
  1. 引数 iterationSet« » を使用して StatementListContainsUndefinedContinueTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 iterationSet« » を使用して StatementListItemContainsUndefinedContinueTarget の実行結果を返す
  1. false を返す

13.2.5 静的セマンティクス(Static Semantics): LexicallyDeclaredNames

Block : {}
  1. 空の新規List を返す
  1. StatementListLexicallyDeclaredNamesnames とする
  2. StatementListItemLexicallyDeclaredNames の要素を names に追加する
  3. names を返す
  1. StatementStatement : LabelledStatement なら、LabelledStatementLexicallyDeclaredNames を返す
  2. 空の新規リストを返す
  1. DeclarationBoundNames を返す

13.2.6 静的セマンティクス(Static Semantics): LexicallyScopedDeclarations

  1. StatementListLexicallyScopedDeclarationsdeclarations とする
  2. StatementListItemLexicallyScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. StatementStatement : LabelledStatement なら、 LabelledStatementLexicallyScopedDeclarations を返す
  2. 空の新規List を返す
  1. DeclarationDeclarationPart を含む新規List を返す

13.2.7 静的セマンティクス(Static Semantics): TopLevelLexicallyDeclaredNames

  1. StatementListTopLevelLexicallyDeclaredNamesnames とする
  2. StatementListItemTopLevelLexicallyDeclaredNames の要素を names に追加する
  3. names を返す
  1. 空の新規List を返す
  1. DeclarationDeclaration : HoistableDeclaration なら、
    1. « » を返す
  2. DeclarationBoundNames を返す
関数またはスクリプトのトップレベルでは、関数宣言はレキシカル宣言ではなくvar宣言のように扱われます。

13.2.8 静的セマンティクス(Static Semantics): TopLevelLexicallyScopedDeclarations

Block : {}
  1. 空の新規List を返す
  1. StatementListTopLevelLexicallyScopedDeclarationsdeclarations とする
  2. StatementListItemTopLevelLexicallyScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. 空の新規List を返す
  1. DeclarationDeclaration : HoistableDeclaration なら、
    1. « » を返す
  2. Declaration を含む新規List を返す

13.2.9 静的セマンティクス(Static Semantics): TopLevelVarDeclaredNames

Block : {}
  1. 空の新規List を返す
  1. StatementListTopLevelVarDeclaredNamesnames とする
  2. StatementListItemTopLevelVarDeclaredNames の要素を names に追加する
  3. names を返す
  1. DeclarationDeclaration : HoistableDeclaration なら、
    1. HoistableDeclarationBoundNames を返す
  2. 空の新規List を返す
  1. StatementStatement : LabelledStatement なら、StatementTopLevelVarDeclaredNames を返す
  2. StatementVarDeclaredNames を返す
関数またはスクリプトのトップレベルでは、内部関数宣言はvar宣言のように扱われます。

13.2.10 静的セマンティクス(Static Semantics): TopLevelVarScopedDeclarations

Block : {}
  1. 空の新規List を返す
  1. StatementListTopLevelVarScopedDeclarationsdeclarations とする
  2. StatementListItemTopLevelVarScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. StatementStatement : LabelledStatement なら、 StatementTopLevelVarScopedDeclarations を返す
  2. StatementVarScopedDeclarations を返す
  1. DeclarationDeclaration : HoistableDeclaration なら、
    1. HoistableDeclarationDeclarationPartdeclaration とする
    2. « declaration » を返す
  2. 空の新規List を返す

13.2.11 静的セマンティクス(Static Semantics): VarDeclaredNames

Block : {}
  1. 空の新規List を返す
  1. StatementListVarDeclaredNamesnames とする
  2. StatementListItemVarDeclaredNames の要素を names に追加する
  3. names を返す
  1. 空の新規List を返す

13.2.12 静的セマンティクス(Static Semantics): VarScopedDeclarations

Block : {}
  1. 空の新規List を返す
  1. StatementListVarScopedDeclarationsdeclarations とする
  2. StatementListItemVarScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. 空の新規List を返す

13.2.13 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

Block : {}
  1. NormalCompletion(empty) を返す
  1. 実行中の実行コンテキストLexicalEnvironmentoldEnv とする
  2. NewDeclarativeEnvironment(oldEnv) を blockEnv とする
  3. BlockDeclarationInstantiation(StatementList , blockEnv) を実行する
  4. blockEnv実行中の実行コンテキストLexicalEnvironment にセットする
  5. StatementList の評価結果を blockValue とする
  6. oldEnv実行中の実行コンテキストLexicalEnvironment にセットする
  7. blockValue を返す
制御がBlockから離れても、LexicalEnvironmentは常に以前の状態に復元されます。
  1. StatementList の評価結果を sl とする
  2. ReturnIfAbrupt(sl)
  3. StatementListItem の評価結果を s とする
  4. Completion(UpdateEmpty(s, sl)) を返す

StatementListの値は、StatementListの値を生成する最後の項目の値です。 たとえば、次のeval関数の呼び出しはすべて値1を返します。

eval("1;;;;;")
eval("1;{}")
eval("1;var a;")

13.2.14 ランタイムセマンティクス(Runtime Semantics): BlockDeclarationInstantiation ( code, env )

BlockまたはCaseBlockが評価されると、新しい宣言型環境レコードが作成され、ブロックで宣言された各ブロックスコープの変数、定数、関数、クラスのバインディングが環境レコードにインスタンス化されます。

BlockDeclarationInstantiationは、引数codeenvを使用して次のように実行されます。 codeは、ブロックの本体に対応するパースノードです。 envは、バインディングが作成されるレキシカル環境です。

  1. envEnvironmentRecordenvRec とする
  2. Assert: envRec宣言型環境レコード
  3. codeLexicallyScopedDeclarationsdeclarations とする
  4. declarations の 各要素を d とし、d ごとに次を実行する
    1. dBoundNames の 各要素を dn とし、dn ごとに次を実行する
      1. dIsConstantDeclarationtrue なら、
        1. ! envRec.CreateImmutableBinding(dn, true) を実行する
      2. i. でなければ、
        1. ! envRec.CreateMutableBinding(dn, false) を実行する
    2. dFunctionDeclarationGeneratorDeclarationAsyncFunctionDeclarationAsyncGeneratorDeclaration のどれかなら、
      1. dBoundNames の唯一の要素を fn とする
      2. 引数 env を使用して dInstantiateFunctionObjectfo とする
      3. envRec.InitializeBinding(fn, fo) を実行する

13.3 宣言と変数ステートメント(Declarations and the Variable Statement)

13.3.1 LetとConst宣言(Let and Const Declarations)

letおよびconst宣言は、実行中の実行コンテキストLexicalEnvironmentにスコープされる変数を定義します。変数は、それらを含むレキシカル環境がインスタンス化されるときに作成されます。ただし、変数のLexicalBindingが評価されるまで、いかなる方法でもアクセスできません。 Initializerを使用してLexicalBindingによって定義された変数は、変数の作成時に値が割り当てられません。割り当てられるのは、LexicalBindingの評価時で InitializerAssignmentExpressionの値が割り当てられます。 let宣言のLexicalBindingInitializerがない場合、LexicalBindingの評価時に、undefined が割り当てられます。
関数実行時、変数は用意されているがアクセスできない。(アクセスするとエラー)
let a = 1; などのコードに到達時に、値が割り当てられる。
letかconstかを判断して変数を定義しているのは13.2.14

構文:

LexicalDeclaration[In, Yield, Await] :
LetOrConst BindingList[?In, ?Yield, ?Await] ;
LetOrConst :
let
const
BindingList[In, Yield, Await] :
LexicalBinding[?In, ?Yield, ?Await]
BindingList[?In, ?Yield, ?Await] ,LexicalBinding[?In, ?Yield, ?Await]
LexicalBinding[In, Yield, Await] :
BindingIdentifier[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]opt
BindingPattern[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]

13.3.1.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

  • BindingListBoundNames"let" を含む場合、構文エラーです
  • BindingListBoundNames に重複するエントリが含まれている場合、構文エラーです

13.3.1.2 静的セマンティクス(Static Semantics): BoundNames

  1. BindingListBoundNames を返す
  1. BindingList の the BoundNamesnames とする
  2. LexicalBindingBoundNames の要素を names に追加する
  3. names を返す
  1. BindingIdentifierBoundNames を返す
  1. BindingPattern の the BoundNames を返す

13.3.1.3 静的セマンティクス(Static Semantics): IsConstantDeclaration

  1. LetOrConstIsConstantDeclaration を返す
  1. false を返す
LetOrConst : const
  1. true を返す

13.3.1.4 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. BindingList の評価結果を next とする
  2. ReturnIfAbrupt(next)
  3. NormalCompletion(empty) を返す
  1. BindingList の評価結果を next とする
  2. ReturnIfAbrupt(next)
  3. LexicalBinding の 評価結果を返す
  1. ResolveBinding(BindingIdentifierStringValue )を lhs とする
  2. InitializeReferencedBinding(lhs, undefined) を返す
静的セマンティックルールにより、この形式の LexicalBinding が const宣言で発生しないことが保証されます。
  1. BindingIdentifierStringValuebindingId とする
  2. ResolveBinding(bindingId) を lhs とする
  3. IsAnonymousFunctionDefinition(Initializer ) が true なら、
    1. 引数 bindingId を使用して InitializerNamedEvaluationvalue とする
  4. 3. でないなら、
    1. Initializer の評価結果を rhs とする
    2. ? GetValue(rhs) を value とする
  5. InitializeReferencedBinding(lhs, value) を返す
  1. Initializer の評価結果を rhs とする
  2. ? GetValue(rhs) を value とする
  3. 実行中の実行コンテキストLexicalEnvironmentenv とする
  4. 引数 valueenv を使用して BindingPatternBindingInitialization の実行結果を返す

13.3.2 変数ステートメント(Variable Statement)

varステートメントは、実行中の実行コンテキストVariableEnvironmentにスコープされる変数を宣言します。var変数は、その変数を含んでいるレキシカル環境がインスタンス化されるときに作成され、同時にundefinedで初期化されます。VariableEnvironmentのスコープ内では、同じBindingIdentifierが複数のVariableDeclarationで宣言される場合がありますが、これらの宣言は1つの変数を定義します。Initializerを使用してVariableDeclarationで定義された変数は、変数の作成時ではなく、VariableDeclarationの実行時にInitializerAssignmentExpressionの値が割り当てられます。
関数実行時、変数はundefinedで初期化される。この時点で変数にアクセスできる。
var a = 1; などのコードに到達時に、実際の値が割り当てられる。

構文:

VariableStatement[Yield, Await] :
varVariableDeclarationList[+In, ?Yield, ?Await] ;
VariableDeclarationList[In, Yield, Await] :
VariableDeclaration[?In, ?Yield, ?Await]
VariableDeclarationList[?In, ?Yield, ?Await] ,VariableDeclaration[?In, ?Yield, ?Await]
VariableDeclaration[In, Yield, Await] :
BindingIdentifier[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]opt
BindingPattern[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]

13.3.2.1 静的セマンティクス(Static Semantics): BoundNames

  1. VariableDeclarationListBoundNamesnames とする
  2. VariableDeclarationBoundNames の要素を names に追加する
  3. names を返す
  1. BindingIdentifier の the BoundNames を返す
  1. BindingPatternBoundNames を返す

13.3.2.2 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. VariableDeclarationListBoundNames を返す

13.3.2.3 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. VariableDeclaration を含む新規List を返す
    1. VariableDeclarationListVarScopedDeclarations を declarations とする

  1. declarationsVariableDeclaration を追加する<
  2. declarations を返す

13.3.2.4 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. VariableDeclarationList の評価結果を next とする
  2. ReturnIfAbrupt(next)
  3. NormalCompletion(empty) を返す
  1. VariableDeclarationList の評価結果を next とする
  2. ReturnIfAbrupt(next)
  3. VariableDeclaration の 評価結果を返す
  1. NormalCompletion(empty) を返す
  1. BindingIdentifierStringValuebindingId とする
  2. ? ResolveBinding(bindingId) を lhs とする
  3. IsAnonymousFunctionDefinition(Initializer ) が true なら、
    1. 引数 bindingId を使用して InitializerNamedEvaluationvalue とする
  4. 3. でないなら、
    1. Initializer の評価結果を rhs とする
    2. ? GetValue(rhs) を value とする
  5. ? PutValue(lhs, value) を返す
VariableDeclarationがwithステートメント内にネストされており、VariableDeclaration内のBindingIdentifierが、withステートメントのオブジェクト環境レコードのバインディングオブジェクトのプロパティ名と同じである場合、ステップ5は、識別子のVariableEnvironmentバインディングに割り当てる代わりに、プロパティに値を割り当てます。
  1. Initializer の評価結果を rhs とする
  2. ? GetValue(rhs) を rval とする
  3. 引数 rvalundefined を使用して BindingPatternBindingInitialization の実行結果を返す

13.3.3 バインディングの分割パターン(Destructuring Binding Patterns)

構文:

BindingPattern[Yield, Await] :
ObjectBindingPattern[?Yield, ?Await]
ArrayBindingPattern[?Yield, ?Await]
ObjectBindingPattern[Yield, Await] :
{}
{BindingRestProperty[?Yield, ?Await] }
{BindingPropertyList[?Yield, ?Await] }
{BindingPropertyList[?Yield, ?Await] ,BindingRestProperty[?Yield, ?Await]opt }
ArrayBindingPattern[Yield, Await] :
[Elisionopt BindingRestElement[?Yield, ?Await]opt ]
[BindingElementList[?Yield, ?Await] ]
[BindingElementList[?Yield, ?Await] ,Elisionopt BindingRestElement[?Yield, ?Await]opt ]
BindingRestProperty[Yield, Await] :
...BindingIdentifier[?Yield, ?Await]
BindingPropertyList[Yield, Await] :
BindingProperty[?Yield, ?Await]
BindingPropertyList[?Yield, ?Await] ,BindingProperty[?Yield, ?Await]
BindingElementList[Yield, Await] :
BindingElisionElement[?Yield, ?Await]
BindingElementList[?Yield, ?Await] ,BindingElisionElement[?Yield, ?Await]
BindingElisionElement[Yield, Await] :
Elisionopt BindingElement[?Yield, ?Await]
BindingProperty[Yield, Await] :
SingleNameBinding[?Yield, ?Await]
PropertyName[?Yield, ?Await] :BindingElement[?Yield, ?Await]
BindingElement[Yield, Await] :
SingleNameBinding[?Yield, ?Await]
BindingPattern[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt
SingleNameBinding[Yield, Await] :
BindingIdentifier[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt
BindingRestElement[Yield, Await] :
...BindingIdentifier[?Yield, ?Await]
...BindingPattern[?Yield, ?Await]

13.3.3.1 静的セマンティクス(Static Semantics): BoundNames

  1. 空の新規List を返す
  1. BindingPropertyListBoundNamesnames とする
  2. BindingRestPropertyBoundNames の要素を names に追加する
  3. names を返す
  1. 空の新規List を返す
  1. BindingRestElementBoundNames を返す
  1. BindingElementListBoundNames を返す
  1. BindingElementListBoundNamesnames とする
  2. BindingRestElementBoundNames の要素を names に追加する
  3. names を返す
  1. BindingPropertyListBoundNamesnames とする
  2. BindingPropertyBoundNames の要素を names に追加する
  3. names を返す
  1. BindingElementListBoundNamesnames とする
  2. BindingElisionElementBoundNames の要素を names に追加する
  3. names を返す
  1. BindingElementBoundNames を返す
  1. BindingElementBoundNames を返す
  1. BindingIdentifierBoundNames を返す
  1. BindingPatternBoundNames を返す

13.3.3.2 静的セマンティクス(Static Semantics): ContainsExpression

  1. false を返す
  1. BindingPropertyListContainsExpression を返す
  1. false を返す
  1. BindingRestElementContainsExpression を返す
  1. BindingElementListContainsExpression を返す
  1. BindingElementListContainsExpressionhas とする
  2. hastrue なら、 true を返す
  3. BindingRestElementContainsExpression を返す
  1. BindingPropertyListContainsExpressionhas とする
  2. hastrue なら、 true を返す
  3. BindingPropertyContainsExpression を返す
  1. BindingElementListContainsExpressionhas とする
  2. hastrue なら、 true を返す
  3. BindingElisionElementContainsExpression を返す
  1. BindingElementContainsExpression を返す
  1. PropertyNameIsComputedPropertyKeyhas とする
  2. hastrue なら、 true を返す
  3. BindingElementContainsExpression を返す
  1. true を返す
  1. false を返す
  1. true を返す
  1. false を返す
  1. BindingPatternContainsExpression を返す

13.3.3.3 静的セマンティクス(Static Semantics): HasInitializer

  1. false を返す
  1. true を返す
  1. false を返す
  1. true を返す

13.3.3.4 静的セマンティクス(Static Semantics): IsSimpleParameterList

  1. false を返す
  1. false を返す
  1. true を返す
  1. false を返す

13.3.3.5 ランタイムセマンティクス(Runtime Semantics): BindingInitialization

引数 valueenvironment を使用。

environmentとしてundefinedが渡された場合、PutValue操作で初期化値を割り当てる必要があることを示します。 これは、非strict関数の正式なパラメーターリストの場合です。 複数の同名パラメーターに対応するために、正式なパラメーターバインディングが事前に初期化されます。
  1. ? RequireObjectCoercible(value) を実行する
  2. 引数 valueenvironment を使用して ObjectBindingPatternBindingInitialization の実行結果を返す
  1. ? GetIterator(value) を iteratorRecord とする
  2. 引数 iteratorRecordenvironment を使用して ArrayBindingPatternIteratorBindingInitializationresult とする
  3. iteratorRecord.[[Done]] が false なら、 ? IteratorClose(iteratorRecord, result)を返す
  4. result を返す
  1. NormalCompletion(empty) を返す
  1. 引数 valueenvironment を使用して ? BindingPropertyListPropertyBindingInitialization を実行する
  2. NormalCompletion(empty) を返す
  1. 空の新規ListexcludedNames とする
  2. 引数 valueenvironmentexcludedNames を使用して BindingRestPropertyRestBindingInitialization の実行結果を返す
  1. 引数 valueenvironment を使用して ? BindingPropertyListPropertyBindingInitializationexcludedNames とする
  2. 引数 valueenvironmentexcludedNames を使用して BindingRestPropertyRestBindingInitialization の実行結果を返す

13.3.3.6 ランタイムセマンティクス(Runtime Semantics): PropertyBindingInitialization

引数 value environment を使用。

これらは、空の完了だけでなく、バインドされたすべてのプロパティ名のリストを収集します。
  1. 引数 valueenvironment を使用して ? BindingPropertyListPropertyBindingInitializationboundNames とする
  2. 引数 valueenvironment を使用して ? BindingPropertyPropertyBindingInitializationnextNames とする
  3. boundNames の 最後に nextNames のアイテムを追加する
  4. boundNames を返す
  1. SingleNameBindingBoundNames の唯一の要素である文字列を name とする
  2. 引数 valueenvironmentname を使用して ? SingleNameBindingKeyedBindingInitialization を実行する
  3. name を含む新規List を返す
  1. PropertyName の評価結果を P とする
  2. ReturnIfAbrupt(P)
  3. 引数 valueenvironmentP を使用して ? BindingElementKeyedBindingInitialization を実行する
  4. P を含む新規List を返す

13.3.3.7 ランタイムセマンティクス(Runtime Semantics): RestBindingInitialization

引数 value environment excludedNames を使用。

  1. ? ResolveBinding(BindingIdentifierStringValue, environment) を lhs とする
  2. OrdinaryObjectCreate(%Object.prototype%) を restObj とする
  3. ? CopyDataProperties(restObj, value, excludedNames) を実行する
  4. environmentundefined なら、 PutValue(lhs, restObj)を返す
  5. InitializeReferencedBinding(lhs, restObj) を返す

13.3.3.8 ランタイムセマンティクス(Runtime Semantics): IteratorBindingInitialization

引数 iteratorRecordenvironment を使用。

environmentがundefinedのとき、PutValue操作で初期化値を割り当てます。 これは、非strict関数の正式なパラメーターリストの場合です。 その場合、複数の同名パラメーターに対応するために、正式なパラメーターバインディングが事前に初期化されます。
  1. NormalCompletion(empty) を返す
  1. 引数 iteratorRecord を使用して ElisionIteratorDestructuringAssignmentEvaluation の実行結果を返す
  1. Elision が 存在するなら、
    1. 引数 iteratorRecord を使用して ? ElisionIteratorDestructuringAssignmentEvaluation を実行する
  2. 引数 iteratorRecordenvironment を使用して BindingRestElementIteratorBindingInitialization の実行結果を返す
  1. 引数 iteratorRecordenvironment を使用して BindingElementListIteratorBindingInitialization の実行結果を返す
  1. 引数 iteratorRecordenvironment を使用して BindingElementListIteratorBindingInitialization の実行結果を返す
  1. 引数 iteratorRecordenvironment を使用して ? BindingElementListIteratorBindingInitialization を実行する
  2. 引数 iteratorRecord を使用して ElisionIteratorDestructuringAssignmentEvaluation の実行結果を返す
  1. 引数 iteratorRecordenvironment を使用して ? BindingElementListIteratorBindingInitialization を実行する
  2. Elision が存在するなら、
    1. 引数 iteratorRecord を使用して ? ElisionIteratorDestructuringAssignmentEvaluation を実行する
  3. 引数 iteratorRecordenvironment を使用して BindingRestElementIteratorBindingInitialization の実行結果を返す
  1. 引数 iteratorRecordenvironment を使用して BindingElisionElementIteratorBindingInitialization の実行結果を返す
  1. 引数 iteratorRecordenvironment を使用して ? BindingElementListIteratorBindingInitialization を実行する
  2. 引数 iteratorRecordenvironment を使用して BindingElisionElementIteratorBindingInitialization の実行結果を返す
  1. 引数 iteratorRecordenvironment を使用して BindingElementIteratorBindingInitialization の実行結果を返す
  1. 引数 iteratorRecord を使用して ? ElisionIteratorDestructuringAssignmentEvaluation を実行する
  2. 引数 iteratorRecordenvironment を使用して BindingElementIteratorBindingInitialization の実行結果を返す
  1. 引数 iteratorRecordenvironment を使用して SingleNameBindingIteratorBindingInitialization の実行結果を返す
  1. BindingIdentifierStringValuebindingId とする
  2. ? ResolveBinding(bindingId, environment) を lhs とする
  3. iteratorRecord.[[Done]] が false なら、
    1. IteratorStep(iteratorRecord) を next とする
    2. next突然の完了 なら、 trueiteratorRecord.[[Done]] にセットする
    3. ReturnIfAbrupt(next)
    4. nextfalse なら、 trueiteratorRecord.[[Done]] にセットする
    5. d. でないなら、
      1. IteratorValue(next) を v とする
      2. v突然の完了 なら、 trueiteratorRecord.[[Done]] にセットする
      3. ReturnIfAbrupt(v)
  4. iteratorRecord.[[Done]] が true なら、 undefinedv とする
  5. Initializer が存在し、 v undefined なら、
    1. IsAnonymousFunctionDefinition(Initializer ) が true なら、
      1. 引数 bindingId を使用して InitializerNamedEvaluation の実行結果を v にセットする
    2. a. でないなら、
      1. Initializer の評価結果を defaultValue とする
      2. ? GetValue(defaultValue) を v にセットする
  6. environmentundefined なら、 ? PutValue(lhs, v)を返す
  7. InitializeReferencedBinding(lhs, v) を返す
  1. iteratorRecord.[[Done]] が false なら、
    1. IteratorStep(iteratorRecord) を next とする
    2. next突然の完了 なら、 trueiteratorRecord.[[Done]] にセットする
    3. ReturnIfAbrupt(next)
    4. nextfalse なら、 trueiteratorRecord.[[Done]] にセットする
    5. d. でないなら、
      1. IteratorValue(next) を v とする
      2. v突然の完了 なら、 trueiteratorRecord.[[Done]] にセットする
      3. ReturnIfAbrupt(v)
  2. iteratorRecord.[[Done]] が true なら、 undefinedv とする
  3. Initializer が存在し、 vundefined なら、
    1. Initializer の評価結果を defaultValue とする
    2. ? GetValue(defaultValue) を v にセットする
  4. 引数 venvironment を使用して BindingPatternBindingInitialization の実行結果を返す
  1. BindingIdentifier , environment) の ? ResolveBinding(StringValuelhs とする
  2. ! ArrayCreate(0) を A とする
  3. 0n とする
  4. 次を繰り返す、
    1. iteratorRecord.[[Done]] が false なら、
      1. IteratorStep(iteratorRecord) を next とする
      2. next突然の完了 なら、 trueiteratorRecord.[[Done]] にセットする
      3. ReturnIfAbrupt(next)
      4. nextfalse なら、 trueiteratorRecord.[[Done]] にセットする
    2. iteratorRecord.[[Done]] が true なら、
      1. environmentundefined なら、 ? PutValue(lhs, A)を返す
      2. InitializeReferencedBinding(lhs, A) を返す
    3. IteratorValue(next) を nextValue とする
    4. nextValue突然の完了 なら、 trueiteratorRecord.[[Done]] にセットする
    5. ReturnIfAbrupt(nextValue)
    6. ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue) を実行する
    7. n + 1n にセットする
  1. ! ArrayCreate(0) を A とする
  2. 0n とする
  3. 次を繰り返す、
    1. iteratorRecord.[[Done]] が false なら、
      1. IteratorStep(iteratorRecord) を next とする
      2. next突然の完了 なら、 trueiteratorRecord.[[Done]] にセットする
      3. ReturnIfAbrupt(next)
      4. nextfalse なら、 trueiteratorRecord.[[Done]] にセットする
    2. iteratorRecord.[[Done]] が true なら、
      1. 引数 Aenvironment を使用して BindingPatternBindingInitialization の実行結果を返す
    3. IteratorValue(next) を nextValue とする
    4. nextValue突然の完了 なら、 trueiteratorRecord.[[Done]] にセットする
    5. ReturnIfAbrupt(nextValue)
    6. ! CreateDataPropertyOrThrow(A, ! ToString(n), nextValue) を実行する
    7. n + 1n にセットする

13.3.3.9 ランタイムセマンティクス(Runtime Semantics): KeyedBindingInitialization

引数 valueenvironmentpropertyName を使用。

environmentがundefinedのとき、PutValue操作で初期化値を割り当てます。 これは、非strict関数の正式なパラメーターリストの場合です。 その場合、複数の同名パラメーターに対応するために、正式なパラメーターバインディングが事前に初期化されます。
  1. ? GetV(value, propertyName) を v とする
  2. Initializer が存在し、 vundefined なら、
    1. Initializer の評価結果を defaultValue とする
    2. ? GetValue(defaultValue) を v にセットする
  3. 引数 venvironment を使用して BindingPatternBindingInitialization の実行結果を返す
  1. BindingIdentifierStringValuebindingId とする
  2. ? ResolveBinding(bindingId, environment) を lhs とする
  3. ? GetV(value, propertyName) を v とする
  4. Initializer が存在し、 vundefined なら、
    1. IsAnonymousFunctionDefinition(Initializer ) が true なら、
      1. 引数 bindingId を使用して InitializerNamedEvaluation の実行結果を v にセットする
    2. a. と異なるなら、
      1. Initializer の評価結果を defaultValue とする
      2. ? GetValue(defaultValue) を v にセットする
  5. environmentundefined なら、 ? PutValue(lhs, v)を返す
  6. InitializeReferencedBinding(lhs, v) を返す

13.4 空文-空のステートメント-(Empty Statement)

構文:

const a=[];
for( let i = 0; i < 5 ; i++) { a.push(i);} // 通常は文が必要
for( let i = 0; i < 5 ; a.push(i++)) ;  // 文のかわりに空文

13.4.1 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. NormalCompletion(empty) を返す

13.5 式ステートメント(Expression Statement)

構文:

ExpressionStatement[Yield, Await] :
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]Expression[+In, ?Yield, ?Await] ;
Blockとあいまいになる可能性があるため、ExpressionStatementU+007B(LEFT CURLY BRACKET: { )で始めることはできません。
FunctionDeclarationGeneratorDeclarationClassDeclarationとあいまいになるため、ExpressionStatementは、functionまたはclassキーワードで開始することはできません。
AsyncFunctionDeclarationAsyncGeneratorDeclarationとあいまいになるため、ExpressionStatementは、async functionで開始することはできません。
最初のLexicalBindingArrayBindingPatternであるとき let LexicalDeclarationとあいまいになるため、ExpressionStatementは、2つのトークンシーケンス let [ で開始できません。

13.5.1 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. Expression の評価結果を exprRef とする
  2. ? GetValue(exprRef) を返す

13.6 ifステートメント(The if Statement)

構文:

IfStatement[Yield, Await, Return] :
if(Expression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return] elseStatement[?Yield, ?Await, ?Return]
if(Expression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

ifelseの対応があいまいで対応するelseがない場合、最も近いifに関連付けられるものとします。

13.6.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

このルールを適用する必要があるのは、B.3.2で指定された拡張機能が実装されている場合のみです。

13.6.2 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. 引数 labelSet を使用して the first StatementContainsDuplicateLabelshasDuplicate とする
  2. hasDuplicatetrue なら、 true を返す
  3. 引数 labelSet を使用して 2番目の StatementContainsDuplicateLabels の実行結果を返す
  1. 引数 labelSet を使用して StatementContainsDuplicateLabels の実行結果を返す

13.6.3 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. 引数 labelSet を使用して the first StatementContainsUndefinedBreakTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 labelSet を使用して 2番目の StatementContainsUndefinedBreakTarget の実行結果を返す
  1. 引数 labelSet を使用して StatementContainsUndefinedBreakTarget の実行結果を返す

13.6.4 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. 引数 iterationSet« » を使用して最初の StatementContainsUndefinedContinueTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 iterationSet« » を使用して2番目の StatementContainsUndefinedContinueTarget の実行結果を返す
  1. 引数 iterationSet« » を使用して StatementContainsUndefinedContinueTarget の実行結果を返す

13.6.5 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. 最初の StatementVarDeclaredNamesnames とする
  2. 2番目の StatementVarDeclaredNames の要素を names に追加する
  3. names を返す
  1. StatementVarDeclaredNames を返す

13.6.6 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. 最初の StatementVarScopedDeclarationsdeclarations とする
  2. 2番目の StatementVarScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. StatementVarScopedDeclarations を返す

13.6.7 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. Expression の評価結果を exprRef とする
  2. ! ToBoolean(? GetValue(exprRef)) を exprValue とする
  3. exprValuetrue なら、
    1. 最初の Statement の評価結果を stmtCompletion とする
  4. 3. と異なるなら、
    1. 2番目の Statement の評価結果を stmtCompletion とする
  5. Completion( UpdateEmpty(stmtCompletion, undefined)) を返す
  1. Expression の評価結果を exprRef とする
  2. ! ToBoolean(? GetValue(exprRef)) を exprValue とする
  3. exprValuefalse なら、
    1. NormalCompletion(undefined) を返す
  4. 8. と異なるなら、
    1. Statement の評価結果を stmtCompletion とする
    2. Completion( UpdateEmpty(stmtCompletion, undefined)) を返す

13.7 反復ステートメント(Iteration Statements)

構文:

IterationStatement[Yield, Await, Return] :

doStatement[?Yield, ?Await, ?Return] while(Expression[+In, ?Yield, ?Await] );

 

while(Expression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

 

for([lookaheadlet []Expression[~In, ?Yield, ?Await]opt ;Expression[+In, ?Yield, ?Await]opt ;Expression[+In, ?Yield, ?Await]opt )Statement[?Yield, ?Await, ?Return]

 

for(varVariableDeclarationList[~In, ?Yield, ?Await] ;Expression[+In, ?Yield, ?Await]opt ;Expression[+In, ?Yield, ?Await]opt )Statement[?Yield, ?Await, ?Return]

 

for(LexicalDeclaration[~In, ?Yield, ?Await] Expression[+In, ?Yield, ?Await]opt ;Expression[+In, ?Yield, ?Await]opt )Statement[?Yield, ?Await, ?Return]

 

for([lookaheadlet []LeftHandSideExpression[?Yield, ?Await] inExpression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

 

for(varForBinding[?Yield, ?Await] inExpression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

 

for(ForDeclaration[?Yield, ?Await] inExpression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

 

for([lookaheadlet]LeftHandSideExpression[?Yield, ?Await] ofAssignmentExpression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

 

for(varForBinding[?Yield, ?Await] ofAssignmentExpression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

 

for(ForDeclaration[?Yield, ?Await] ofAssignmentExpression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

 

[+Await]forawait([lookaheadlet]LeftHandSideExpression[?Yield, ?Await] ofAssignmentExpression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

 

[+Await]forawait(varForBinding[?Yield, ?Await] ofAssignmentExpression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

 

[+Await]forawait(ForDeclaration[?Yield, ?Await] ofAssignmentExpression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]

ForDeclaration[Yield, Await] :

LetOrConst ForBinding[?Yield, ?Await]

ForBinding[Yield, Await] :

BindingIdentifier[?Yield, ?Await]

 

BindingPattern[?Yield, ?Await]
このセクションは、付録B.3.6によって拡張されています。

13.7.1 セマンティクス(Semantics)

13.7.1.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

このルールを適用する必要があるのは、B.3.2で指定された拡張機能が実装されている場合のみです。

13.7.1.2 ランタイムセマンティクス(Runtime Semantics): LoopContinues ( completion, labelSet )

引数completionおよびlabelSetを使用した抽象操作LoopContinuesは、次の手順で定義されます。

  1. completion.[[Type]] が normal なら、 true を返す
  2. completion.[[Type]] が continue でないなら、 false を返す
  3. completion.[[Target]] が empty なら、 true を返す
  4. completion.[[Target]] が labelSet の要素なら、 true を返す
  5. false を返す
IterationStatementStatementパート内で、ContinueStatementを使用して新しい反復を開始できます。

13.7.2 do-whileステートメント(The do-while Statement)

13.7.2.1 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsDuplicateLabels の実行結果を返す

13.7.2.2 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsUndefinedBreakTarget の実行結果を返す

13.7.2.3 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. 引数 iterationSet« » を使用して StatementContainsUndefinedContinueTarget の実行結果を返す

13.7.2.4 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. StatementVarDeclaredNames を返す

13.7.2.5 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. StatementVarScopedDeclarations を返す

13.7.2.6 ランタイムセマンティクス(Runtime Semantics): LabelledEvaluation

引数 labelSet を使用。

  1. undefinedV とする
  2. 繰り返す、
    1. Statement の評価結果を stmtResult とする
    2. LoopContinues(stmtResult, labelSet) が false なら、 Completion( UpdateEmpty(stmtResult, V))を返す
    3. stmtResult.[[Value]] が empty でないなら、 stmtResult.[[Value]] を V にセットする
    4. Expression の評価結果を exprRef とする
    5. ? GetValue(exprRef) を exprValue とする
    6. ! ToBoolean(exprValue) が false なら、 NormalCompletion(V)を返す

13.7.3 whileステートメント(The while Statement)

13.7.3.1 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsDuplicateLabels の実行結果を返す

13.7.3.2 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsUndefinedBreakTarget の実行結果を返す

13.7.3.3 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. 引数 iterationSet« » を使用して StatementContainsUndefinedContinueTarget の実行結果を返す

13.7.3.4 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. StatementVarDeclaredNames を返す

13.7.3.5 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. StatementVarScopedDeclarations を返す

13.7.3.6 ランタイムセマンティクス(Runtime Semantics): LabelledEvaluation

引数 labelSet を使用。

  1. undefinedV とする
  2. 繰り返す
    1. Expression の評価結果を exprRef とする
    2. ? GetValue(exprRef) を exprValue とする
    3. ! ToBoolean(exprValue) が false なら、 NormalCompletion(V)を返す
    4. Statement の評価結果を stmtResult とする
    5. LoopContinues(stmtResult, labelSet) が false なら、 Completion( UpdateEmpty(stmtResult, V))を返す
    6. stmtResult.[[Value]] が empty でないなら、 stmtResult.[[Value]] を V にセットする

13.7.4 forステートメント(The for Statement)

13.7.4.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

13.7.4.2 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsDuplicateLabels の実行結果を返す

13.7.4.3 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsUndefinedBreakTarget の実行結果を返す

13.7.4.4 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. 引数 iterationSet« » を使用して StatementContainsUndefinedContinueTarget の実行結果を返す

13.7.4.5 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. Statement の the VarDeclaredNames を返す
  1. VariableDeclarationListBoundNamesnames とする
  2. StatementVarDeclaredNames の要素を names に追加する
  3. names を返す
  1. StatementVarDeclaredNames を返す

13.7.4.6 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. StatementVarScopedDeclarations を返す
  1. VariableDeclarationListVarScopedDeclarationsdeclarations とする
  2. StatementVarScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. StatementVarScopedDeclarations を返す

13.7.4.7 ランタイムセマンティクス(Runtime Semantics): LabelledEvaluation

引数 labelSet を使用。

  1. 最初の Expression が存在するなら、
    1. 最初の Expression の評価結果を exprRef とする
    2. ? GetValue(exprRef) を実行する
  2. ? ForBodyEvaluation(2番目の Expression , 3番目の Expression , Statement , « », labelSet) を返す
  1. VariableDeclarationList の評価結果を varDcl とする
  2. ReturnIfAbrupt(varDcl)
  3. ? ForBodyEvaluation(最初の Expression , 2番目の Expression , Statement , « », labelSet) を返す
  1. 実行中の実行コンテキストLexicalEnvironmentoldEnv とする
  2. NewDeclarativeEnvironment(oldEnv) を loopEnv とする
  3. loopEnvEnvironmentRecordloopEnvRec とする
  4. LexicalDeclarationIsConstantDeclarationisConst とする
  5. LexicalDeclarationBoundNamesboundNames とする
  6. boundNames の 各要素を dn とし、dn ごとに次を実行する
    1. isConsttrue なら、
      1. ! loopEnvRec.CreateImmutableBinding(dn, true) を実行する
    2. a. と異なるなら、
      1. ! loopEnvRec.CreateMutableBinding(dn, false) を実行する
  7. loopEnv実行中の実行コンテキストLexicalEnvironment にセットする
  8. LexicalDeclaration の評価結果を forDcl とする
  9. forDcl突然の完了 なら、
    1. oldEnv実行中の実行コンテキストLexicalEnvironment にセットする
    2. Completion(forDcl) を返す
  10. isConstfalse なら boundNames を、 異なるなら « »perIterationLets とする
  11. ForBodyEvaluation(最初の Expression , 2番目の Expression , Statement , perIterationLets, labelSet) を bodyResult とする
  12. oldEnv実行中の実行コンテキスト's LexicalEnvironment にセットする
  13. Completion(bodyResult) を返す

13.7.4.8 ランタイムセマンティクス(Runtime Semantics): ForBodyEvaluation ( test, increment, stmt, perIterationBindings, labelSet )

引数test, increment, stmt, perIterationBindings, labelSetを使用した抽象操作ForBodyEvaluationは、次のように実行されます。

  1. undefinedV とする
  2. ? CreatePerIterationEnvironment(perIterationBindings) を実行する
  3. 繰り返す、
    1. test が [empty] でないなら、
      1. test の評価結果を testRef とする
      2. ? GetValue(testRef) を testValue とする
      3. ! ToBoolean(testValue) が false なら、 NormalCompletion(V) を返す
    2. stmt の評価結果を result とする
    3. LoopContinues(result, labelSet) が false なら、 Completion( UpdateEmpty(result, V)) を返す
    4. result.[[Value]] が empty でないなら、 result.[[Value]] を V にセットする
    5. ? CreatePerIterationEnvironment(perIterationBindings) を実行する
    6. increment が [empty] でないなら、
      1. increment の評価結果を incRef とする
      2. ? GetValue(incRef) を実行する

13.7.4.9 ランタイムセマンティクス(Runtime Semantics): CreatePerIterationEnvironment ( perIterationBindings )

引数 perIterationBindingsを使用した抽象操作CreatePerIterationEnvironmentは、次のように実行されます。

  1. perIterationBindings に要素があるなら、
    1. 実行中の実行コンテキストLexicalEnvironmentlastIterationEnv とする
    2. lastIterationEnvEnvironmentRecordlastIterationEnvRec とする
    3. lastIterationEnv外部環境参照outer とする
    4. Assert: outernull ではない
    5. NewDeclarativeEnvironment(outer) を thisIterationEnv とする
    6. thisIterationEnvEnvironmentRecordthisIterationEnvRec とする
    7. perIterationBindings の 各要素を bn とし、bn ごとに次を実行する
      1. ! thisIterationEnvRec.CreateMutableBinding(bn, false) を実行する
      2. ? lastIterationEnvRec.GetBindingValue(bn, true) を lastValue とする
      3. thisIterationEnvRec.InitializeBinding(bn, lastValue) を実行する
    8. thisIterationEnv実行中の実行コンテキストLexicalEnvironment にセットする
  2. undefined を返す

13.7.5 for-in、for-of、for-await-ofステートメント(The for-in, for-of, and for-await-of Statements)

13.7.5.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

LeftHandSideExpressionObjectLiteral またはArrayLiteral の場合、次の早期エラールールが適用されます。

LeftHandSideExpressionObjectLiteralArrayLiteral のどちらでもない場合、次の早期エラールールが適用されます。

  • ForDeclarationBoundNames"let" を含んでいる場合、構文エラーです
  • ForDeclarationBoundNames の要素が StatementVarDeclaredNames でも出現する場合、構文エラーです
  • ForDeclarationBoundNames に重複する要素が含まれている場合、構文エラーです

13.7.5.2 静的セマンティクス(Static Semantics): BoundNames

  1. ForBindingBoundNames を返す

13.7.5.3 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsDuplicateLabels の実行結果を返す
このセクションは、付録B.3.6によって拡張されています。

13.7.5.4 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsUndefinedBreakTarget の実行結果を返す
このセクションは、付録B.3.6によって拡張されています。

13.7.5.5 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. 引数 iterationSet« » を使用して StatementContainsUndefinedContinueTarget の実行結果を返す
このセクションは、付録B.3.6によって拡張されています。

13.7.5.6 静的セマンティクス(Static Semantics): IsDestructuring

  1. ForBindingIsDestructuring を返す
  1. false を返す
  1. true を返す
このセクションは、付録B.3.6によって拡張されています。

13.7.5.7 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. StatementVarDeclaredNames を返す
  1. ForBindingBoundNamesnames とする
  2. StatementVarDeclaredNames の要素を names に追加する
  3. names を返す
このセクションは、付録B.3.6によって拡張されています。

13.7.5.8 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. StatementVarScopedDeclarations を返す
  1. ForBinding を含む Listdeclarations とする
  2. StatementVarScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
このセクションは、付録B.3.6によって拡張されています。

13.7.5.9 ランタイムセマンティクス(Runtime Semantics): BindingInitialization

引数 valueenvironment を使用。

varステートメントおよび一部の非strict関数の仮パラメーターリストの場合(9.2.10を参照)、environmentundefinedが指定されたとき、PutValueで初期化値を割り当てる必要があります。 このとき、レキシカルバインディングは、初期化子の評価の前に巻き上げられ、事前に初期化されます。
  1. 引数 valueenvironment を使用して ForBindingBindingInitialization の実行結果を返す

13.7.5.10 ランタイムセマンティクス(Runtime Semantics): BindingInstantiation

引数 environment を使用。

  1. environmentEnvironmentRecordenvRec とする
  2. Assert: envRec宣言型環境レコード
  3. ForBindingBoundNames の 各要素を name とし、name ごとに次を実行する
    1. LetOrConstIsConstantDeclarationtrue なら、
      1. ! envRec.CreateImmutableBinding(name, true) を実行する
    2. a. と異なるなら、
      1. ! envRec.CreateMutableBinding(name, false) を実行する

13.7.5.11 ランタイムセマンティクス(Runtime Semantics): LabelledEvaluation

引数 labelSet を使用。

  1. ? ForIn/OfHeadEvaluation(« », Expression , enumerate) を keyResult とする
  2. ? ForIn/OfBodyEvaluation(LeftHandSideExpression , Statement , keyResult, enumerate, assignment, labelSet) を返す
  1. ? ForIn/OfHeadEvaluation(« », Expression , enumerate) を keyResult とする
  2. ? ForIn/OfBodyEvaluation(ForBinding , Statement , keyResult, enumerate, varBinding, labelSet) を返す
  1. ? ForIn/OfHeadEvaluation( ForDeclarationBoundNames , Expression , enumerate) を keyResult とする
  2. ? ForIn/OfBodyEvaluation(ForDeclaration , Statement , keyResult, enumerate, lexicalBinding, labelSet) を返す
  1. ? ForIn/OfHeadEvaluation(« », AssignmentExpression , iterate) を keyResult とする
  2. ? ForIn/OfBodyEvaluation(LeftHandSideExpression , Statement , keyResult, iterate, assignment, labelSet) を返す
  1. ? ForIn/OfHeadEvaluation(« », AssignmentExpression , iterate) を keyResult とする
  2. ? ForIn/OfBodyEvaluation(ForBinding , Statement , keyResult, iterate, varBinding, labelSet) を返す
  1. ? ForIn/OfHeadEvaluation(ForDeclarationBoundNames , AssignmentExpression , iterate) を keyResult とする
  2. ? ForIn/OfBodyEvaluation(ForDeclaration , Statement , keyResult, iterate, lexicalBinding, labelSet) を返す
  1. ? ForIn/OfHeadEvaluation(« », AssignmentExpression , async-iterate) を keyResult とする
  2. ? ForIn/OfBodyEvaluation(LeftHandSideExpression , Statement , keyResult, iterate, assignment, labelSet, async) を返す
  1. ? ForIn/OfHeadEvaluation(« », AssignmentExpression , async-iterate) を keyResult とする
  2. ? ForIn/OfBodyEvaluation(ForBinding , Statement , keyResult, iterate, varBinding, labelSet, async) を返す
  1. ? ForIn/OfHeadEvaluation( ForDeclarationBoundNames , AssignmentExpression , async-iterate) を keyResult とする
  2. ? ForIn/OfBodyEvaluation(ForDeclaration , Statement , keyResult, iterate, lexicalBinding, labelSet, async) を返す
このセクションは、付録B.3.6によって拡張されています。

13.7.5.12 ランタイムセマンティクス(Runtime Semantics): ForIn/OfHeadEvaluation ( uninitializedBoundNames, expr, iterationKind )

抽象演算For/OfHeadEvaluationは、引数uninitializedBoundNames, expr, iterationKindを使用して呼び出されます。 iterationKindの値は、enumerateiterateasync-iterateのいずれかです。

  1. 実行中の実行コンテキストLexicalEnvironmentoldEnv とする
  2. uninitializedBoundNames が空のリストでないなら、
    1. Assert: uninitializedBoundNames の要素は重複なし
    2. NewDeclarativeEnvironment(oldEnv) を newEnv とする
    3. newEnvEnvironmentRecordnewEnvRec とする
    4. uninitializedBoundNames の文字列要素を name とし、各 name ごとに次を実行する
      1. ! newEnvRec.CreateMutableBinding(name, false) を実行する
    5. newEnv実行中の実行コンテキストLexicalEnvironment にセットする
  3. expr の評価結果を exprRef とする
  4. oldEnv実行中の実行コンテキストLexicalEnvironment にセットする
  5. ? GetValue(exprRef) を exprValue とする
  6. iterationKindenumerate なら、
    1. exprValueundefinednull なら、
      1. Completion { [[Type]]: break, [[Value]]: empty, [[Target]]: empty } を返す
    2. ! ToObject(exprValue) を obj とする
    3. ? EnumerateObjectProperties(obj) を返す
  7. 6. と異なるなら、
    1. Assert: iterationKinditerateasync-iterate
    2. iterationKindasync-iterate なら、 asynciteratorHint とする
    3. b. と異なるなら、 synciteratorHint とする
    4. ? GetIterator(exprValue, iteratorHint) を返す

13.7.5.13 ランタイムセマンティクス(Runtime Semantics): ForIn/OfBodyEvaluation ( lhs, stmt, iteratorRecord, iterationKind, lhsKind, labelSet [ , iteratorKind ] )

抽象操作ForIn/OfBodyEvaluationは、引数lhsstmtiteratorRecorditerationKindlhsKindlabelSet、およびオプションの引数iteratorKindを使用して呼び出されます。 lhsKindの値は、assignmentvarBindinglexicalBindingのいずれかです。 iteratorKindの値は、syncまたはasyncです。

  1. iteratorKind が存在しないなら、 synciteratorKind にセットする
  2. 実行中の実行コンテキストLexicalEnvironmentoldEnv とする
  3. undefinedV とする
  4. lhsIsDestructuringdestructuring とする
  5. destructuringtruelhsKindassignment なら、
    1. Assert: lhsLeftHandSideExpression
    2. lhs によってカバーされているAssignmentPatternassignmentPattern とする
  6. 繰り返す
    1. ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]) を nextResult とする
    2. iteratorKindasync なら、 ? Await(nextResult) を nextResult にセットする
    3. Type(nextResult) が Object型 でないなら、 TypeError例外をスローする
    4. ? IteratorComplete(nextResult) を done とする
    5. donetrue なら、 NormalCompletion(V) を返す
    6. ? IteratorValue(nextResult) を nextValue とする
    7. lhsKindassignmentvarBinding なら、
      1. destructuringfalse なら、
        1. lhs の評価結果を lhsRef とする。 (繰り返し評価される場合があり)
    8. g. と異なるなら、
      1. Assert: lhsKindlexicalBinding
      2. Assert: lhsForDeclaration
      3. NewDeclarativeEnvironment(oldEnv) を iterationEnv とする
      4. 引数 iterationEnv を使用して、lhsBindingInstantiation を実行する
      5. iterationEnv実行中の実行コンテキストLexicalEnvironment にセットする
      6. destructuringfalse なら、
        1. Assert: lhs は単一の名前をバインドしている
        2. lhsBoundNames の唯一の要素を lhsName とする
        3. ! ResolveBinding(lhsName) を lhsRef とする
    9. destructuringfalse なら、
      1. lhsRef が an 突然の完了 なら、
        1. lhsRefstatus とする
      2. i. と異なるなり、 lhsKindlexicalBinding なら、
        1. InitializeReferencedBinding(lhsRef, nextValue) を status とする
      3. ii. と異なるなら、
        1. PutValue(lhsRef, nextValue) を status とする
    10. i. と異なるなら、
      1. lhsKindassignment なら、
        1. 引数 nextValue を使用して assignmentPatternDestructuringAssignmentEvaluationstatus とする
      2. i. と異なるなり、 lhsKindvarBinding なら、
        1. Assert: lhsForBinding
        2. 引数 nextValueundefined を使用して lhsBindingInitializationstatus とする
      3. ii. と異なるなら、
        1. Assert: lhsKindlexicalBinding
        2. Assert: lhsForDeclaration
        3. 引数 nextValueiterationEnv を使用して lhsBindingInitializationstatus とする
    11. status突然の完了 なら、
      1. oldEnv実行中の実行コンテキストLexicalEnvironment にセットする
      2. iteratorKindasync なら、 ? AsyncIteratorClose(iteratorRecord, status) を返す
      3. iterationKindenumerate なら、
        1. status を返す
      4. iii. と異なるなら、
        1. Assert: iterationKinditerate
        2. ? IteratorClose(iteratorRecord, status) を返す
    12. stmt の評価結果を result とする
    13. oldEnv実行中の実行コンテキストLexicalEnvironment にセットする
    14. LoopContinues(result, labelSet) が false なら、
      1. iterationKindenumerate なら、
        1. Completion( UpdateEmpty(result, V)) を返す
      2. i. と異なるなら、
        1. Assert: iterationKinditerate
        2. UpdateEmpty(result, V) を status にセットする
        3. iteratorKindasync なら、 ? AsyncIteratorClose(iteratorRecord, status) を返す
        4. ? IteratorClose(iteratorRecord, status) を返す
    15. result.[[Value]] が empty でないなら、 result.[[Value]] を V にセットする

13.7.5.14 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. BindingIdentifierStringValuebindingId とする
  2. ? ResolveBinding(bindingId) を返す

13.7.5.15 EnumerateObjectProperties ( O )

抽象操作EnumerateObjectPropertiesが引数 Oで呼び出されると、次の手順が実行されます。

  1. Assert: Type(O) は Object型
  2. nextメソッドが、 O の列挙可能なプロパティキーを反復処理するIteratorオブジェクト(25.1.1.2)を返す。iteratorオブジェクトにECMAScriptコードから直接アクセスすることはできない。 プロパティを列挙するメカニズムと順序は指定されていない。ただし、以下に指定されているルールに準拠している必要がある。

イテレータのthrowメソッドとreturnメソッドはnullであり、呼び出されることはありません。 nextメソッドは、オブジェクトのプロパティを処理して、プロパティキーをイテレータ値として返す必要があるかどうかを判断します。 返されるプロパティキーには、シンボルキーは含まれません。 ターゲットオブジェクトのプロパティは、列挙中に削除されることがあります。 nextメソッドの処理前に削除されたプロパティは無視されます。 列挙中に新しいプロパティが追加された場合は、そのプロパティが列挙処理されるかどうかを保証されません。 プロパティ名は、nextメソッドで、一度だけ返されます。

ターゲットオブジェクトのプロパティ列挙は、プロトタイプのプロパティ、プロトタイプのプロトタイプを再帰的に列挙することなどが含まれます。 ただし、プロトタイプのプロパティは、nextメソッドによって処理済のプロパティと同名のものは処理されません。 [[Enumerable]]属性の値は、プロトタイプオブジェクトのプロパティがすでに処理されているかどうかの判断時に考慮されません。 プロトタイプオブジェクトの列挙可能なプロパティ名は、プロトタイプオブジェクトを引数として渡してEnumerateObjectPropertiesを呼び出すことによって取得します。 EnumerateObjectPropertiesは、[[OwnPropertyKeys]]内部メソッドを呼び出して、ターゲットオブジェクトの独自プロパティキーを取得します。 ターゲットオブジェクトのプロパティ属性は、その[[GetOwnProperty]]内部メソッドを呼び出すことによって取得します。

さらに、Oおよび、プロトタイプチェーン内のオブジェクトが、 ProxyエキゾチックオブジェクトInteger-Indexedエキゾチックオブジェクトモジュールネームスペースエキゾチックオブジェクト、または実装提供のエキゾチックオブジェクトのどれでもない場合、次のいずれかが発生するまで、イテレータはCreateForInIterator(O)で指定されたイテレータと同じように動作する必要があります。

  • O の [[Prototype]]内部スロットまたは、そのプロトタイプチェーン内のオブジェクトの値が変更される
  • プロパティが O またはそのプロトタイプチェーン内のオブジェクトから削除される
  • O のプロトタイプチェーン内のオブジェクトにプロパティが追加される
  • O のプロパティまたは、そのプロトタイプチェーン内のオブジェクトの[[Enumerable]]属性の値が変更される
ホストは、13.7.5.16.2.1のアルゴリズムを直接実装する必要はありません。 前の段落の制約の1つに違反しない限り、動作がそのアルゴリズムから逸脱しない実装を選択できます。以下は、これらのルールに準拠するECMAScriptジェネレーター関数の定義です。

function* EnumerateObjectProperties(obj) {
  const visited = new Set();
  for (const key of Reflect.ownKeys(obj)) {
    if (typeof key === "symbol") continue;
    const desc = Reflect.getOwnPropertyDescriptor(obj, key);
    if (desc) {
      visited.add(key);
      if (desc.enumerable) yield key;
    }
  }
  const proto = Reflect.getPrototypeOf(obj);
  if (proto === null) return;
  for (const protoKey of EnumerateObjectProperties(proto)) {
    if (!visited.has(protoKey)) yield protoKey;
  }
}
実装が歴史的にこれらのケースの動作で異なっていたため、実装がCreateForInIteratorと一致する必要がないエキゾチックなオブジェクトのリストを選択しています。そして、他のすべてのケースで合意されています。

13.7.5.16 For-Inイテレーターオブジェクト(For-In Iterator Objects)

For-Inイテレーターは、特定のオブジェクトに対して反復をおこなうオブジェクトです。 For-Inイテレーターオブジェクトは、ECMAScriptコードに直接アクセスすることはできません。 これらは、EnumerateObjectPropertiesの動作を説明するためだけに存在します。

13.7.5.16.1 CreateForInIterator ( object )

引数objectを使用した抽象操作CreateForInIteratorは、objectの独自かつ継承可能で列挙可能な文字列プロパティを特定の順序で反復する For-Inイテレーターオブジェクトを作成するために使用されます。 次の手順を実行します。

  1. Assert: Type(object) は Object型
  2. OrdinaryObjectCreate(%ForInIteratorPrototype%, « [[Object]], [[ObjectWasVisited]], [[VisitedKeys]], [[RemainingKeys]] ») を iterator とする
  3. objectiterator.[[Object]] にセットする
  4. falseiterator.[[ObjectWasVisited]] にセットする
  5. 空の新規Listiterator.[[VisitedKeys]] にセットする
  6. 空の新規Listiterator.[[RemainingKeys]] にセットする
  7. iterator を返す
13.7.5.16.2 The %ForInIteratorPrototype% Object

%ForInIteratorPrototype%オブジェクトは、

  • すべてのFor-Inイテレータオブジェクトに継承されるプロパティがあります。
  • 通常のオブジェクトです。
  • [[Prototype]]内部スロットがあり、その値は組み込みオブジェクト%IteratorPrototype% です。
  • ECMAScriptコードに直接アクセスすることはできません。
  • 以降のプロパティを所持しています。
13.7.5.16.2.1 %ForInIteratorPrototype%.next ( )
  1. this値を O とする
  2. Assert: Type(O) は Object型
  3. Assert: O は、For-Inイテレータインスタンスのすべての内部スロットがある (13.7.5.16.3)
  4. O.[[Object]] を object とする
  5. O.[[VisitedKeys]] を visited とする
  6. O.[[RemainingKeys]] を remaining とする
  7. 繰り返す、
    1. O.[[ObjectWasVisited]] が false なら、
      1. ? object.[[OwnPropertyKeys]]() を keys とする
      2. リスト順に keys の 各要素を key とし、key ごとに次を実行する
        1. Type(key) が String型 なら、
          1. remainingkey を追加する
      3. trueO.[[ObjectWasVisited]] にセットする
    2. remaining がemptyでない間繰り返し、
      1. remaining から最初の要素を削除し、要素の値を r とする
      2. SameValue(r, v) が true となる要素 vvisited に存在しないなら、
        1. ? object.[[GetOwnProperty]](r) を desc とする
        2. descundefined でないなら、
          1. visitedr を追加する
          2. desc.[[Enumerable]] が true なら、 CreateIterResultObject(r, false) を返す
    3. ? object.[[GetPrototypeOf]]() を object にセットする
    4. objectO.[[Object]] にセットする
    5. falseO.[[ObjectWasVisited]] にセットする
    6. objectnull なら、 CreateIterResultObject(undefined, true) を返す
13.7.5.16.3 For-Inイテレータインスタンスのプロパティ(Properties of For-In Iterator Instances)

For-Inイテレータインスタンスは、%ForInIteratorPrototype%組み込みオブジェクトからプロパティを継承する通常のオブジェクトです。 For-Inイテレータインスタンスは、最初に表36にリストされている内部スロットを使用して作成されます。

表36: For-Inイテレータインスタンスの内部スロット
内部スロット 内容
[[Object]] 対象オブジェクト
[[ObjectWasVisited]] イテレータが[[Object]]で[[OwnPropertyKeys]]を呼び出した場合はtrue、それ以外の場合はfalse
[[VisitedKeys]] 発行済文字列値リスト
[[RemainingKeys]] プロトタイプのプロパティを反復する前に、現在のオブジェクトで未出力の文字列値のリスト(プロトタイプがnullでない場合)。

13.8 continueステートメント(The continue Statement)

構文:

ContinueStatement[Yield, Await] :

continue;
continue[no LineTerminator here]LabelIdentifier[?Yield, ?Await] ;

13.8.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

ContinueStatement :

continue;
  • ContinueStatement が直接または間接的に(ただし、関数の境界を越えない)ネストされていない場合、 IterationStatement 内で構文エラーになります。

13.8.2 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

ContinueStatement :

continue;
  1. false を返す
  1. LabelIdentifierStringValueiterationSet の要素でないなら、 true を返す
  2. false を返す

13.8.3 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

ContinueStatement :

continue;
  1. Completion { [[Type]]: continue, [[Value]]: empty, [[Target]]: empty } を返す
  1. LabelIdentifierStringValuelabel とする
  2. Completion { [[Type]]: continue, [[Value]]: empty, [[Target]]: label } を返す

13.9 breakステートメント(The break Statement)

構文:

BreakStatement[Yield, Await] :

break;
break[no LineTerminator here]LabelIdentifier[?Yield, ?Await] ;

13.9.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

BreakStatement :

break;

13.9.2 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

BreakStatement :

break;
  1. false を返す
  1. LabelIdentifierStringValuelabelSet の要素でないなら、 true を返す
  2. false を返す

13.9.3 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

BreakStatement :

break;
  1. Completion { [[Type]]: break, [[Value]]: empty, [[Target]]: empty } を返す
  1. LabelIdentifierStringValuelabel とする
  2. Completion { [[Type]]: break, [[Value]]: empty, [[Target]]: label } を返す

13.10 returnステートメント(The return Statement)

構文:

ReturnStatement[Yield, Await] :

return;
return[no LineTerminator here]Expression[+In, ?Yield, ?Await] ;
returnステートメントは関数の実行を停止し、呼び出し元に値を返します。Expressionを省略した場合、戻り値はundefinedです。 それ以外の戻り値はExpressionの値です。 周囲のコンテキストによっては、returnステートメントが呼び出し元に値を返さない場合があります。 たとえば、tryブロックでは、finallyブロックの評価中に、returnステートメントの完了レコードが別の完了レコードに置き換えられる場合があります。

13.10.1 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

ReturnStatement :

return;
  1. Completion { [[Type]]: return, [[Value]]: undefined, [[Target]]: empty } を返す
  1. Expression の評価結果を exprRef とする
  2. ? GetValue(exprRef) を exprValue とする
  3. ! GetGeneratorKind() が async なら、 ? Await(exprValue) を exprValue にセットする
  4. Completion { [[Type]]: return, [[Value]]: exprValue, [[Target]]: empty } を返す

13.11 withステートメント(The with Statement)

構文:

WithStatement[Yield, Await, Return] :

with(Expression[+In, ?Yield, ?Await] )Statement[?Yield, ?Await, ?Return]
withステートメントは、計算されたオブジェクトのオブジェクト環境レコードを、実行中の実行コンテキストのレキシカル環境に追加します。 次に、この拡張されたレキシカル環境を使用してステートメントを実行します。 最後に、元のレキシカル環境を復元します。

13.11.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

B.3.2で指定された拡張機能が実装されている場合にのみ、2番目のルールを適用する必要があります。

13.11.2 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsDuplicateLabels の実行結果を返す

13.11.3 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. 引数 labelSet を使用して StatementContainsUndefinedBreakTarget の実行結果を返す

13.11.4 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. 引数 iterationSet« » を使用して StatementContainsUndefinedContinueTarget の実行結果を返す

13.11.5 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. StatementVarDeclaredNames を返す

13.11.6 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. Statement の the VarScopedDeclarations を返す

13.11.7 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. Expression の評価結果を val とする
  2. ? ToObject(? GetValue(val)) を obj とする
  3. 実行中の実行コンテキストLexicalEnvironmentoldEnv とする
  4. NewObjectEnvironment(obj, oldEnv) を newEnv とする
  5. truenewEnvEnvironmentRecordwithEnvironment フラグにセットする
  6. newEnv実行中の実行コンテキストLexicalEnvironment にセットする
  7. Statement の評価結果を C とする
  8. oldEnv実行中の実行コンテキストLexicalEnvironment にセットする
  9. Completion( UpdateEmpty(C, undefined)) を返す
制御が埋め込まれたStatementをどのように(通常、突然の完了、例外に関わらず)離れても、LexicalEnvironmentは常に以前の状態に復元されます。

13.12 switchステートメント(The switch Statement)

構文:

SwitchStatement[Yield, Await, Return] :

switch(Expression[+In, ?Yield, ?Await] )CaseBlock[?Yield, ?Await, ?Return]
CaseBlock[Yield, Await, Return] :

{CaseClauses[?Yield, ?Await, ?Return]opt }
{CaseClauses[?Yield, ?Await, ?Return]opt DefaultClause[?Yield, ?Await, ?Return] CaseClauses[?Yield, ?Await, ?Return]opt }
CaseClauses[Yield, Await, Return] :

CaseClause[?Yield, ?Await, ?Return]
CaseClauses[?Yield, ?Await, ?Return] CaseClause[?Yield, ?Await, ?Return]
CaseClause[Yield, Await, Return] :

caseExpression[+In, ?Yield, ?Await] :StatementList[?Yield, ?Await, ?Return]opt
DefaultClause[Yield, Await, Return] :

default:StatementList[?Yield, ?Await, ?Return]opt

13.12.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

  • 重複するエントリが CaseBlockLexicallyDeclaredNames に含まれている場合、構文エラーになります。
  • CaseBlockLexicallyDeclaredNames の要素が CaseBlockVarDeclaredNames でも発生する場合は、構文エラーです。

13.12.2 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. 引数 labelSet を使用して CaseBlockContainsDuplicateLabels の実行結果を返す
CaseBlock :

{}
  1. false を返す
  1. 最初の CaseClauses が存在するなら、
    1. 引数 labelSet を使用して 最初の CaseClausesContainsDuplicateLabelshasDuplicates とする
    2. hasDuplicatestrue なら、 true を返す
  2. 引数 labelSet を使用して DefaultClauseContainsDuplicateLabelshasDuplicates とする
  3. hasDuplicatestrue なら、 true を返す
  4. 2番目の CaseClauses が存在しないなら、 false を返す
  5. 引数 labelSet を使用して 2番目の CaseClausesContainsDuplicateLabels の実行結果を返す
  1. 引数 labelSet を使用して CaseClausesContainsDuplicateLabelshasDuplicates とする
  2. hasDuplicatestrue なら、 true を返す
  3. 引数 labelSet を使用して CaseClauseContainsDuplicateLabels の実行結果を返す
  1. StatementList が存在するなら、 引数 labelSet を使用して StatementListContainsDuplicateLabels の実行結果を返す
  2. false を返す
  1. StatementList が存在するなら、 引数 labelSet を使用して StatementListContainsDuplicateLabels の実行結果を返す
  2. false を返す

13.12.3 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. 引数 labelSet を使用して CaseBlockContainsUndefinedBreakTarget の実行結果を返す
CaseBlock :

{}
  1. false を返す
  1. 最初の CaseClauses が存在するなら、
    1. 引数 labelSet を使用して 最初の CaseClausesContainsUndefinedBreakTargethasUndefinedLabels とする
    2. hasUndefinedLabelstrue なら、 true を返す
  2. 引数 labelSet を使用して DefaultClauseContainsUndefinedBreakTargethasUndefinedLabels とする
  3. hasUndefinedLabelstrue なら、 true を返す
  4. 2番目の CaseClauses が存在しないなら、 false を返す
  5. 引数 labelSet を使用して 2番目の CaseClausesContainsUndefinedBreakTarget の実行結果を返す
  1. 引数 labelSet を使用して CaseClausesContainsUndefinedBreakTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 labelSet を使用して CaseClauseContainsUndefinedBreakTarget の実行結果を返す
  1. StatementList が存在するなら、 引数 labelSet を使用して StatementListContainsUndefinedBreakTarget の実行結果を返す
  2. false を返す
  1. StatementList が存在するなら、 引数 labelSet を使用して StatementListContainsUndefinedBreakTarget の実行結果を返す
  2. false を返す

13.12.4 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. 引数 iterationSet« » を使用して CaseBlockContainsUndefinedContinueTarget の実行結果を返す
CaseBlock :

{}
  1. false を返す
  1. 最初の CaseClauses が存在するなら、
    1. 引数 iterationSet« » を使用して 最初の CaseClausesContainsUndefinedContinueTargethasUndefinedLabels とする
    2. hasUndefinedLabelstrue なら、 true を返す
  2. 引数 iterationSet« » を使用して DefaultClauseContainsUndefinedContinueTargethasUndefinedLabels とする
  3. hasUndefinedLabelstrue なら、 true を返す
  4. 2番目の CaseClauses が存在しないなら、 false を返す
  5. 引数 iterationSet« » を使用して 2番目の CaseClausesContainsUndefinedContinueTarget の実行結果を返す
  1. 引数 iterationSet« » を使用して CaseClausesContainsUndefinedContinueTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 iterationSet« » を使用して CaseClauseContainsUndefinedContinueTarget の実行結果を返す
  1. StatementList が存在するなら、 引数 iterationSet« » を使用して StatementListContainsUndefinedContinueTarget の実行結果を返す
  2. false を返す
  1. StatementList が存在するなら、 引数 iterationSet« » を使用して StatementListContainsUndefinedContinueTarget の実行結果を返す
  2. false を返す

13.12.5 静的セマンティクス(Static Semantics): LexicallyDeclaredNames

CaseBlock :

{}
  1. 空の新規List を返す
  1. 最初の CaseClauses が存在するなら、最初の CaseClausesLexicallyDeclaredNamesnames とする
  2. 2. と異なるなら、 空の新規Listnames とする
  3. DefaultClauseLexicallyDeclaredNames の要素を names に追加する
  4. 2番目の CaseClauses が存在しないなら、 names を返す
  5. 2番目の CaseClausesLexicallyDeclaredNames の要素を names に追加した結果を返す
  1. CaseClausesLexicallyDeclaredNamesnames とする
  2. CaseClauseLexicallyDeclaredNames の要素を names に追加する
  3. names を返す
  1. StatementList が存在するなら、 StatementListLexicallyDeclaredNames を返す
  2. 空の新規List を返す
  1. StatementList が存在するなら、 StatementListLexicallyDeclaredNames を返す
  2. 空の新規List を返す

13.12.6 静的セマンティクス(Static Semantics): LexicallyScopedDeclarations

CaseBlock :

{}
  1. 空の新規List を返す
  1. 最初の CaseClauses が存在するなら、 最初の CaseClausesLexicallyScopedDeclarationsdeclarations とする
  2. 2. と異なるなら、 空の新規Listdeclarations とする
  3. DefaultClauseLexicallyScopedDeclarations の要素を declarations に追加する
  4. 2番目の CaseClauses が存在しないなら、 declarations を返す
  5. 2番目の CaseClausesLexicallyScopedDeclarations の要素を declarations に追加した結果を返す
  1. CaseClausesLexicallyScopedDeclarationsdeclarations とする
  2. CaseClauseLexicallyScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. StatementList が存在するなら、 StatementListLexicallyScopedDeclarations を返す
  2. 空の新規List を返す
  1. StatementList が存在するなら、 StatementList の the LexicallyScopedDeclarations を返す
  2. 空の新規List を返す

13.12.7 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. CaseBlockVarDeclaredNames を返す
CaseBlock :

{}
  1. 空の新規List を返す
  1. 最初の CaseClauses が存在するなら、 最初の CaseClausesVarDeclaredNamesnames とする
  2. 3. と異なるなら、 空の新規Listnames とする
  3. DefaultClauseVarDeclaredNames の要素を names に追加する
  4. 2番目の CaseClauses が 存在しないなら、 を返す names
  5. 2番目の CaseClausesVarDeclaredNames の要素を names に追加した結果を返す
  1. CaseClausesVarDeclaredNamesnames とする
  2. CaseClauseVarDeclaredNames の要素を names に追加する
  3. names を返す
  1. StatementList が存在するなら、 StatementListVarDeclaredNames を返す
  2. 空の新規List を返す
  1. StatementList が存在するなら、 StatementListVarDeclaredNames を返す
  2. 空の新規List を返す

13.12.8 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. CaseBlockVarScopedDeclarations を返す
CaseBlock :

{}
  1. 空の新規List を返す
  1. 最初の CaseClauses が存在するなら、 最初の CaseClausesVarScopedDeclarationsdeclarations とする
  2. 3. と異なるなら、 空の新規Listdeclarations とする
  3. DefaultClauseVarScopedDeclarations の要素を declarations に追加する
  4. 2番目の CaseClauses が存在しないなら、 declarations を返す
  5. 2番目の CaseClausesVarScopedDeclarations の要素を declarations に追加した結果を返す
  1. CaseClausesVarScopedDeclarationsdeclarations とする
  2. CaseClauseVarScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. StatementList が存在するなら、 StatementListVarScopedDeclarations を返す
  2. 空の新規List を返す
  1. StatementList が存在するなら、 StatementListVarScopedDeclarations を返す
  2. 空の新規List を返す

13.12.9 ランタイムセマンティクス(Runtime Semantics): CaseBlockEvaluation

引数 input を使用。

CaseBlock :

{}
  1. NormalCompletion(undefined) を返す
  1. undefinedV とする
  2. CaseClausesCaseClauseアイテムを、ソーステキスト順で List にしたものを A とする
  3. falsefound とする
  4. A の 各 CaseClauseC とし、 C ごとに次を実行する
    1. foundfalse なら、
      1. ? CaseClauseIsSelected(C, input) を found にセットする
    2. foundtrue なら、
      1. C の評価結果を R とする
      2. R.[[Value]] が empty でないなら、 R.[[Value]] を V にセットする
      3. R 突然の完了 なら、 Completion( UpdateEmpty(R, V)) を返す
  5. NormalCompletion(V) を返す
  1. undefinedV とする
  2. 最初の CaseClauses が 存在するなら、
    1. 最初の CaseClausesCaseClause アイテムをソーステキスト順のリストにしたものを A とする
  3. 8. と異なるなら、
    1. « »A とする
  4. falsefound とする
  5. A の 各 CaseClauseC とし、 C ごとに次を実行する
    1. foundfalse なら、
      1. ? CaseClauseIsSelected(C, input) を found にセットする
    2. foundtrue なら、
      1. C の評価結果を R とする
      2. R.[[Value]] が empty でないなら、 R.[[Value]] を V にセットする
      3. R突然の完了 なら、 Completion( UpdateEmpty(R, V)) を返す
  6. falsefoundInB とする
  7. 2番目の CaseClauses が存在するなら、
    1. 2番目の CaseClausesCaseClauseアイテムをソーステキスト順のリストにしたものを B とする
  8. 13. と異なるなら、
    1. « »B とする
  9. foundfalse なら、
    1. B の 各 CaseClauseC とし C ごとに次を実行する
      1. foundInBfalse なら、
        1. ? CaseClauseIsSelected(C, input) を foundInB にセットする
      2. foundInBtrue なら、
        1. CaseClause C の評価結果を R とする
        2. R.[[Value]] が empty でないなら、 R.[[Value]] を V にセットする
        3. R突然の完了 なら、 Completion( UpdateEmpty(R, V)) を返す
  10. foundInBtrue なら、 NormalCompletion(V) を返す
  11. DefaultClause の評価結果を R とする
  12. R.[[Value]] が empty でないなら、 R.[[Value]] を V にセットする
  13. R突然の完了 なら、 Completion( UpdateEmpty(R, V)) を返す
  14. NOTE: 以下は、2番目のCaseClausesの反復です。
  15. B の 各 CaseClauseC とし、 C ごとに次を実行する
    1. C の評価結果を R とする
    2. R.[[Value]] が empty でないなら、 R.[[Value]] を V にセットする
    3. R突然の完了 なら、 Completion( UpdateEmpty(R, V)) を返す
  16. NormalCompletion(V) を返す

13.12.10 ランタイムセマンティクス(Runtime Semantics): CaseClauseIsSelected ( C, input )

抽象演算CaseClauseIsSelectedは、CaseClause C と値inputが与えられると、C が入力と一致するかどうかを判別します。

  1. Assert: C は プロダクション CaseClause : caseExpression :StatementListopt のインスタンス
  2. CExpression の評価結果を exprRef とする
  3. ? GetValue(exprRef) を clauseSelector とする
  4. 厳密等値比較 input === clauseSelector の実行結果を返す
この操作は、CStatementList(存在する場合)を実行しません。 CaseBlock アルゴリズムは、その戻り値を使用して、実行を開始するStatementListを決定します。

13.12.11 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. Expression の評価結果を exprRef とする
  2. ? GetValue(exprRef) を switchValue とする
  3. 実行中の実行コンテキストLexicalEnvironmentoldEnv とする
  4. NewDeclarativeEnvironment(oldEnv) を blockEnv とする
  5. BlockDeclarationInstantiation(CaseBlock , blockEnv) を実行する
  6. blockEnv実行中の実行コンテキストLexicalEnvironment にセットする
  7. 引数 switchValue を使用して CaseBlockCaseBlockEvaluationR とする
  8. oldEnv実行中の実行コンテキストLexicalEnvironment にセットする
  9. R を返す
制御がSwitchStatementからどのように離れても、LexicalEnvironmentは常に以前の状態に復元されます。
  1. NormalCompletion(empty) を返す
  1. StatementList の 評価結果を返す
DefaultClause :

default:
  1. NormalCompletion(empty) を返す
  1. StatementList の 評価結果を返す

13.13 ラベル付きステートメント(Labelled Statements)

構文:

LabelledStatement[Yield, Await, Return] :

LabelIdentifier[?Yield, ?Await] :LabelledItem[?Yield, ?Await, ?Return]
LabelledItem[Yield, Await, Return] :

Statement[?Yield, ?Await, ?Return]
FunctionDeclaration[?Yield, ?Await, ~Default]
ラベル付きステートメントは、ラベルとbreaおよびcontinueステートメントと組み合わせてのみ使用されます。 ECMAScriptにはgotoステートメントがありません。 ステートメントはLabelledStatementの一部にすることができ、それ自体はLabelledStatementの一部にすることができます。 この方法で導入されたラベルは、個々のステートメントのセマンティクスで、まとめて「現在のラベルセット」と呼びます。

13.13.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

  • ソーステキストがこのルールに一致する場合は、構文エラーです。
このルールの代替定義がB.3.2に記載されています。

13.13.2 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. LabelIdentifierStringValuelabel とする
  2. labellabelSet の要素なら、 true を返す
  3. label を追加した labelSet のコピーを newLabelSet とする
  4. 引数 newLabelSet を使用して LabelledItemContainsDuplicateLabels の実行結果を返す
  1. false を返す

13.13.3 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. LabelIdentifierStringValuelabel とする
  2. label を追加した labelSet のコピーを newLabelSet とする
  3. 引数 newLabelSet を使用して LabelledItemContainsUndefinedBreakTarget の実行結果を返す
  1. false を返す

13.13.4 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. LabelIdentifier の the StringValuelabel とする
  2. label を追加した labelSet のコピーを newLabelSet とする
  3. 引数 iterationSetnewLabelSet を使用して LabelledItemContainsUndefinedContinueTarget の実行結果を返す
  1. false を返す

13.13.5 静的セマンティクス(Static Semantics): IsLabelledFunction ( stmt )

引数stmtを指定した抽象操作IsLabelledFunctionは、次の手順を実行します。

  1. stmtLabelledStatement でないなら、 false を返す
  2. stmtLabelledItemitem とする
  3. itemLabelledItem : FunctionDeclarationなら、 true を返す
  4. itemStatementsubStmt とする
  5. IsLabelledFunction(subStmt) を返す

13.13.6 静的セマンティクス(Static Semantics): LexicallyDeclaredNames

  1. LabelledItemLexicallyDeclaredNames を返す
  1. 空の新規List を返す
  1. FunctionDeclarationBoundNames を返す

13.13.7 静的セマンティクス(Static Semantics): LexicallyScopedDeclarations

  1. LabelledItem の the LexicallyScopedDeclarations を返す
  1. 空の新規List を返す
  1. FunctionDeclaration を含む新規List を返す

13.13.8 静的セマンティクス(Static Semantics): TopLevelLexicallyDeclaredNames

  1. 空の新規List を返す

13.13.9 静的セマンティクス(Static Semantics): TopLevelLexicallyScopedDeclarations

  1. 空の新規List を返す

13.13.10 静的セマンティクス(Static Semantics): TopLevelVarDeclaredNames

  1. LabelledItemTopLevelVarDeclaredNames を返す
  1. StatementStatement : LabelledStatement なら、 StatementTopLevelVarDeclaredNames を返す
  2. StatementVarDeclaredNames を返す
  1. FunctionDeclarationBoundNames を返す

13.13.11 静的セマンティクス(Static Semantics): TopLevelVarScopedDeclarations

  1. LabelledItemTopLevelVarScopedDeclarations を返す
  1. StatementStatement : LabelledStatement なら、 StatementTopLevelVarScopedDeclarations を返す
  2. StatementVarScopedDeclarations を返す
  1. FunctionDeclaration を含む新規List を返す

13.13.12 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. LabelledItemVarDeclaredNames を返す
  1. 空の新規List を返す

13.13.13 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. LabelledItemVarScopedDeclarations を返す
  1. 空の新規List を返す

13.13.14 ランタイムセマンティクス(Runtime Semantics): LabelledEvaluation

引数 labelSet を使用。

  1. LabelIdentifierStringValuelabel とする
  2. labelSet の要素として label を追加する
  3. 引数 labelSet を使用して LabelledItemLabelledEvaluationstmtResult とする
  4. stmtResult.[[Type]] が breakSameValue(stmtResult.[[Target]] , label) が true なら、
    1. NormalCompletion(stmtResult.[[Value]]) を stmtResult にセットする
  5. Completion(stmtResult) を返す
  1. StatementLabelledStatementBreakableStatement なら、
    1. 引数 labelSet を使用して StatementLabelledEvaluation の実行結果を返す
  2. 6. と異なるなら、
    1. Statement の 評価結果を返す
  1. FunctionDeclaration の 評価結果を返す

13.13.15 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. 空の新規ListnewLabelSet とする
  2. 引数 newLabelSet を使用して LabelledStatementLabelledEvaluation の実行結果を返す

13.14 throwステートメント(The throw Statement)

構文:

ThrowStatement[Yield, Await] :

throw[no LineTerminator here]Expression[+In, ?Yield, ?Await] ;

13.14.1 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. Expression の評価結果を exprRef とする
  2. ? GetValue(exprRef) を exprValue とする
  3. ThrowCompletion(exprValue) を返す

13.15 tryステートメント(The try Statement)

構文:

TryStatement[Yield, Await, Return] :

tryBlock[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return]
tryBlock[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return]
tryBlock[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return]
Catch[Yield, Await, Return] :

catch(CatchParameter[?Yield, ?Await] )Block[?Yield, ?Await, ?Return]
catchBlock[?Yield, ?Await, ?Return]
Finally[Yield, Await, Return] :

finallyBlock[?Yield, ?Await, ?Return]
CatchParameter[Yield, Await] :

BindingIdentifier[?Yield, ?Await]
BindingPattern[?Yield, ?Await]
tryステートメントは、ランタイムエラーやthrowステートメントなどの例外的な条件が発生する可能性のあるコードをブロックで囲みます。 catch句は、例外発生時の処理コードを記述します。 catch句が例外をキャッチすると、そのCatchParameterが例外にバインドされます。

13.15.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)

  • CatchParameterBoundNames の要素が重複している場合、構文エラー
  • CatchParameterBoundNames の要素が BlockLexicallyDeclaredNames にもある場合は、構文エラー
  • CatchParameterBoundNames の要素が BlockVarDeclaredNames にもある場合は、構文エラーです。
このプロダクションの代替の静的セマンティクスが、B.3.5に記載されています。

13.15.2 静的セマンティクス(Static Semantics): ContainsDuplicateLabels

引数 labelSet を使用。

  1. 引数 labelSet を使用して BlockContainsDuplicateLabelshasDuplicates とする
  2. hasDuplicatestrue なら、 true を返す
  3. 引数 labelSet を使用して CatchContainsDuplicateLabels の実行結果を返す
  1. 引数 labelSet を使用して BlockContainsDuplicateLabelshasDuplicates とする
  2. hasDuplicatestrue なら、 true を返す
  3. 引数 labelSet を使用して FinallyContainsDuplicateLabels の実行結果を返す
  1. 引数 labelSet を使用して BlockContainsDuplicateLabelshasDuplicates とする
  2. hasDuplicatestrue なら、 true を返す
  3. 引数 labelSet を使用して CatchContainsDuplicateLabelshasDuplicates とする
  4. hasDuplicatestrue なら、 true を返す
  5. 引数 labelSet を使用して FinallyContainsDuplicateLabels の実行結果を返す
  1. 引数 labelSet を使用して BlockContainsDuplicateLabels の実行結果を返す

13.15.3 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget

引数 labelSet を使用。

  1. 引数 labelSet を使用して BlockContainsUndefinedBreakTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 labelSet を使用して CatchContainsUndefinedBreakTarget の実行結果を返す
  1. 引数 labelSet を使用して BlockContainsUndefinedBreakTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 labelSet を使用して FinallyContainsUndefinedBreakTarget の実行結果を返す
  1. 引数 labelSet を使用して BlockContainsUndefinedBreakTarget hasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 labelSet を使用して CatchContainsUndefinedBreakTargethasUndefinedLabels とする
  4. hasUndefinedLabelstrue なら、 true を返す
  5. 引数 labelSet を使用して FinallyContainsUndefinedBreakTarget の実行結果を返す
  1. 引数 labelSet を使用して BlockContainsUndefinedBreakTarget の実行結果を返す

13.15.4 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget

引数 iterationSetlabelSet を使用。

  1. 引数 iterationSet« » を使用して BlockContainsUndefinedContinueTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 iterationSet« » を使用して CatchContainsUndefinedContinueTarget の実行結果を返す
  1. 引数 iterationSet« » を使用して BlockContainsUndefinedContinueTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 iterationSet« » を使用して FinallyContainsUndefinedContinueTarget の実行結果を返す
  1. 引数 iterationSet« » を使用して BlockContainsUndefinedContinueTargethasUndefinedLabels とする
  2. hasUndefinedLabelstrue なら、 true を返す
  3. 引数 iterationSet« » を使用して CatchContainsUndefinedContinueTargethasUndefinedLabels とする
  4. hasUndefinedLabelstrue なら、 true を返す
  5. 引数 iterationSet« » を使用して FinallyContainsUndefinedContinueTarget の実行結果を返す
  1. 引数 iterationSet« » を使用して BlockContainsUndefinedContinueTarget の実行結果を返す

13.15.5 静的セマンティクス(Static Semantics): VarDeclaredNames

  1. BlockVarDeclaredNamesnames とする
  2. CatchVarDeclaredNames の要素を names に追加する
  3. names を返す
  1. BlockVarDeclaredNamesnames とする
  2. FinallyVarDeclaredNames の要素を names に追加する
  3. names を返す
  1. BlockVarDeclaredNamesnames とする
  2. CatchVarDeclaredNames の要素を names に追加する
  3. FinallyVarDeclaredNames の要素を names に追加する
  4. names を返す
  1. Block の the VarDeclaredNames を返す

13.15.6 静的セマンティクス(Static Semantics): VarScopedDeclarations

  1. BlockVarScopedDeclarationsdeclarations とする
  2. CatchVarScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. BlockVarScopedDeclarationsdeclarations とする
  2. FinallyVarScopedDeclarations の要素を declarations に追加する
  3. declarations を返す
  1. BlockVarScopedDeclarationsdeclarations とする
  2. CatchVarScopedDeclarations の要素を declarations に追加する
  3. FinallyVarScopedDeclarations の要素を declarations に追加する
  4. declarations を返す
  1. BlockVarScopedDeclarations を返す

13.15.7 ランタイムセマンティクス(Runtime Semantics): CatchClauseEvaluation

引数 thrownValue を使用。

  1. 実行中の実行コンテキストLexicalEnvironmentoldEnv とする
  2. NewDeclarativeEnvironment(oldEnv) を catchEnv とする
  3. catchEnvEnvironmentRecordcatchEnvRec とする
  4. CatchParameterBoundNames の 各要素を argName とし、argName ごとに次を実行する
    1. ! catchEnvRec.CreateMutableBinding(argName, false) を実行する
  5. catchEnv実行中の実行コンテキストLexicalEnvironment にセットする
  6. 引数 thrownValuecatchEnv を使用して CatchParameterBindingInitializationstatus とする
  7. status突然の完了 なら、
    1. oldEnv実行中の実行コンテキストLexicalEnvironment にセットする
    2. Completion(status) を返す
  8. Block の評価結果を B とする
  9. oldEnv実行中の実行コンテキストLexicalEnvironment にセットする
  10. Completion(B) を返す
Catch :

catchBlock
  1. Block の 評価結果を返す
制御がBlockをどのように離れても、LexicalEnvironmentは常に以前の状態に復元されます。

13.15.8 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

  1. Block の評価結果を B とする
  2. B.[[Type]] が throw なら、 引数 B.[[Value]] を使用して CatchCatchClauseEvaluationC とする
  3. 2. と異なるなら、 BC とする
  4. Completion( UpdateEmpty(C, undefined)) を返す
  1. Block の評価結果を B とする
  2. Finally の評価結果を F とする
  3. F.[[Type]] が normal なら、 BF にセットする
  4. Completion( UpdateEmpty(F, undefined)) を返す
  1. Block の評価結果を B とする
  2. B.[[Type]] が throw なら、引数 B.[[Value]] を使用して CatchCatchClauseEvaluationC とする
  3. 10. と異なるなら、 BC とする
  4. Finally の評価結果を F とする
  5. F.[[Type]] が normal なら、 CF にセットする
  6. Completion( UpdateEmpty(F, undefined)) を返す

13.16 debuggerステートメント(The debugger Statement)

構文:

DebuggerStatement :

debugger;

13.16.1 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)

デバッガーで実行時、DebuggerStatementの評価は、実装がブレークポイントを発生させる可能性があります。 デバッガーが存在しないかアクティブでない場合、このステートメントは影響を及ぼしません。
DebuggerStatement :

debugger;
  1. 実装定義のデバッグ機能が利用可能で有効になっているなら、
    1. 実装定義のデバッグアクションを実行する
    2. 実装定義の Completion 値を result とする
  2. 1. と異なるなら、
    1. NormalCompletion(empty) を result とする
  3. result を返す